Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Popup): new prop closeOnScroll close popup when scroll outside of it #21453

Merged
merged 3 commits into from
Jan 26, 2022

Conversation

YuanboXue-Amber
Copy link
Contributor

When popup's trigger is rendered outside of a scrollable container, popperjs is not able to find the scrollable parent of the trigger element, and it can cause the trigger to detach from popup itself:
https://codesandbox.io/s/fluent-ui-example-forked-yxmwv?file=/example.js:0-1198
image

For cases like this, a new prop closeOnScroll is added to Popup, so when the scroll happens in the container, the popup can be dismissed.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 26, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 68aad08:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration
fluent-ui-example (forked) PR

@fabricteam
Copy link
Collaborator

fabricteam commented Jan 26, 2022

📊 Bundle size report

🤖 This report was generated against d525c8b2106551865d648873210a6b48c2326ecb

@size-auditor
Copy link

size-auditor bot commented Jan 26, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-northstar-Popup 146.04 kB 146.089 kB ExceedsBaseline     49 bytes
office-ui-fabric-react fluentui-react-northstar-Toolbar 188.478 kB 188.526 kB ExceedsBaseline     48 bytes
office-ui-fabric-react fluentui-react-northstar-SplitButton 192.261 kB 192.308 kB ExceedsBaseline     47 bytes
office-ui-fabric-react fluentui-react-northstar-Datepicker 201.149 kB 201.196 kB ExceedsBaseline     47 bytes
office-ui-fabric-react fluentui-react-northstar-MenuButton 175.995 kB 176.041 kB ExceedsBaseline     46 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: d525c8b2106551865d648873210a6b48c2326ecb (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Jan 26, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1113 1103 5000
BaseButton mount 1083 1100 5000
Breadcrumb mount 2893 2863 1000
ButtonNext mount 578 591 5000
Checkbox mount 1805 1784 5000
CheckboxBase mount 1522 1546 5000
ChoiceGroup mount 5478 5519 5000
ComboBox mount 1079 1150 1000
CommandBar mount 11282 11213 1000
ContextualMenu mount 9321 9314 1000
DefaultButton mount 1328 1317 5000
DetailsRow mount 4303 4304 5000
DetailsRowFast mount 4321 4269 5000
DetailsRowNoStyles mount 4041 4037 5000
Dialog mount 2838 2853 1000
DocumentCardTitle mount 220 229 1000
Dropdown mount 3661 3662 5000
FluentProviderNext mount 2036 1984 5000
FluentProviderWithTheme mount 191 209 10
FluentProviderWithTheme virtual-rerender 137 132 10
FluentProviderWithTheme virtual-rerender-with-unmount 216 232 10
FocusTrapZone mount 2003 2056 5000
FocusZone mount 1943 2040 5000
IconButton mount 2053 2016 5000
Label mount 402 409 5000
Layer mount 3376 3395 5000
Link mount 548 571 5000
MakeStyles mount 1794 1785 50000
MenuButton mount 1738 1718 5000
MessageBar mount 2193 2230 5000
Nav mount 3747 3671 1000
OverflowSet mount 1275 1273 5000
Panel mount 2702 2771 1000
Persona mount 970 955 1000
Pivot mount 1661 1633 1000
PrimaryButton mount 1517 1502 5000
Rating mount 8929 9067 5000
SearchBox mount 1571 1571 5000
Shimmer mount 3016 2952 5000
Slider mount 2303 2240 5000
SpinButton mount 5614 5588 5000
Spinner mount 515 507 5000
SplitButton mount 3570 3618 5000
Stack mount 636 643 5000
StackWithIntrinsicChildren mount 2688 2821 5000
StackWithTextChildren mount 6354 6464 5000
SwatchColorPicker mount 12910 13039 5000
TagPicker mount 3071 3038 5000
TeachingBubble mount 14527 14666 5000
Text mount 525 562 5000
TextField mount 1635 1587 5000
ThemeProvider mount 1374 1384 5000
ThemeProvider virtual-rerender 700 719 5000
ThemeProvider virtual-rerender-with-unmount 2160 2205 5000
Toggle mount 951 944 5000
buttonNative mount 175 177 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AccordionMinimalPerf.default 186 161 1.16:1
AttachmentMinimalPerf.default 205 179 1.15:1
HeaderSlotsPerf.default 986 877 1.12:1
AnimationMinimalPerf.default 661 602 1.1:1
CardMinimalPerf.default 695 646 1.08:1
ListWith60ListItems.default 792 730 1.08:1
RadioGroupMinimalPerf.default 565 521 1.08:1
AvatarMinimalPerf.default 248 231 1.07:1
FlexMinimalPerf.default 346 322 1.07:1
ListNestedPerf.default 687 645 1.07:1
ImageMinimalPerf.default 465 437 1.06:1
DropdownManyItemsPerf.default 830 790 1.05:1
ListCommonPerf.default 780 742 1.05:1
LoaderMinimalPerf.default 805 769 1.05:1
PopupMinimalPerf.default 722 688 1.05:1
IconMinimalPerf.default 732 695 1.05:1
AttachmentSlotsPerf.default 1307 1257 1.04:1
BoxMinimalPerf.default 413 397 1.04:1
ChatDuplicateMessagesPerf.default 353 338 1.04:1
SkeletonMinimalPerf.default 440 422 1.04:1
SliderMinimalPerf.default 1881 1811 1.04:1
TextAreaMinimalPerf.default 617 594 1.04:1
ButtonSlotsPerf.default 656 634 1.03:1
CarouselMinimalPerf.default 540 524 1.03:1
ChatWithPopoverPerf.default 427 416 1.03:1
DialogMinimalPerf.default 872 843 1.03:1
ProviderMergeThemesPerf.default 1855 1801 1.03:1
DatepickerMinimalPerf.default 6328 6180 1.02:1
GridMinimalPerf.default 407 398 1.02:1
InputMinimalPerf.default 1461 1426 1.02:1
MenuMinimalPerf.default 1022 999 1.02:1
MenuButtonMinimalPerf.default 1941 1904 1.02:1
RefMinimalPerf.default 286 281 1.02:1
SplitButtonMinimalPerf.default 4996 4893 1.02:1
StatusMinimalPerf.default 812 796 1.02:1
TableManyItemsPerf.default 2259 2206 1.02:1
CustomToolbarPrototype.default 4590 4500 1.02:1
ToolbarMinimalPerf.default 1090 1069 1.02:1
CheckboxMinimalPerf.default 2984 2940 1.01:1
DividerMinimalPerf.default 439 434 1.01:1
EmbedMinimalPerf.default 4670 4636 1.01:1
HeaderMinimalPerf.default 437 433 1.01:1
PortalMinimalPerf.default 188 186 1.01:1
ProviderMinimalPerf.default 1262 1251 1.01:1
TableMinimalPerf.default 490 487 1.01:1
ChatMinimalPerf.default 859 855 1:1
LabelMinimalPerf.default 471 473 1:1
TooltipMinimalPerf.default 1180 1179 1:1
TreeMinimalPerf.default 941 938 1:1
ButtonOverridesMissPerf.default 1899 1914 0.99:1
DropdownMinimalPerf.default 3297 3355 0.98:1
FormMinimalPerf.default 486 496 0.98:1
RosterPerf.default 1335 1363 0.98:1
SegmentMinimalPerf.default 409 418 0.98:1
ItemLayoutMinimalPerf.default 1381 1424 0.97:1
AlertMinimalPerf.default 319 337 0.95:1
ListMinimalPerf.default 607 642 0.95:1
ReactionMinimalPerf.default 467 492 0.95:1
TextMinimalPerf.default 419 441 0.95:1
TreeWith60ListItems.default 218 230 0.95:1
VideoMinimalPerf.default 711 753 0.94:1
LayoutMinimalPerf.default 440 472 0.93:1
ButtonMinimalPerf.default 215 235 0.91:1

@@ -170,6 +173,7 @@ export const Popup: React.FC<PopupProps> &
unstable_disableTether,
unstable_pinned,
autoSize,
closeOnScroll,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's have a test in cypress for this, it should be pretty straightforward to trigger a scroll event on the window

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

Copy link
Member

@ling1726 ling1726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need to handle this in v9 Popover too, do you want to do the honours ? or just create an issue to track :)

@YuanboXue-Amber
Copy link
Contributor Author

YuanboXue-Amber commented Jan 26, 2022

I think we will need to handle this in v9 Popover too, do you want to do the honours ? or just create an issue to track :)

Oh yeah I forgot about it totally 🙈 let me create an issue

update: here it is: #21457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fluent UI react-northstar (v0) Work related to Fluent UI V0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants